//先找到发表按钮
var tj = document.querySelector('.add-to');
var input = document.querySelector('.title>input');
tj.onclick = function() {
	if(input.value !== "") {
		//创建元素
		//  div
		var div = document.createElement('div');
		document.querySelector('.main').appendChild(div);

		//  p
		var ipt = document.createElement('input');
		ipt.className = "ipt";
		ipt.readOnly = 'true';
		ipt.value = input.value;
		input.value = '';
		div.appendChild(ipt);

		//时间
		var time = document.createElement('span');
		var myDate = new Date();
		var mytime = myDate.toLocaleTimeString();
		time.innerHTML = mytime;
		div.appendChild(time);
		//  button 删除
		var btn1 = document.createElement('button');
		btn1.innerHTML = '删除';
		div.appendChild(btn1);

		btn1.onclick = function() {
			this.parentElement.parentElement.removeChild(this.parentElement);
		}

		//  button 修改
		var btn2 = document.createElement('button');
		btn2.innerHTML = '修改';
		div.appendChild(btn2);
		var xiugai = document.querySelector(".xiugai");
		var inp = document.querySelector(".xiugai>input");
		var but = document.querySelector(".xiugai>button");
		var inp1 = document.querySelector(".ipt");
		//	console.log(inp);
		//	console.log(inp1);

		btn2.onclick = function() {
			var xiugai = document.createElement('p');
			xiugai.className = 'xiugai';
			div.appendChild(xiugai);
			var inp = document.createElement('input');
			xiugai.appendChild(inp);
			var but = document.createElement('button');
			but.innerHTML = '确定';
			xiugai.appendChild(but);
			but.onclick = function() {
				if(inp.value !== "") {
					var inp1 = document.querySelector(".ipt");
					inp1 = this.parentElement.parentElement.firstChild;
					inp1.value = inp.value;
					xiugai.style.display = 'none';
				} else {
					var inp1 = document.querySelector(".ipt");
					inp1.value = inp1.value;
					xiugai.style.display = 'none';
				}
			}
		}
	} else {
		alert("请输入内容");
	}
}

//手机端
var i = document.querySelector(".head>i");
var left = document.querySelector(".matter-left");
i.addEventListener('click', function() {
	left.style.left = '0px';
	left.style.transition = 'all 1s';
})
left.addEventListener('click', function() {
	left.style.left = '-280px';
	left.style.transition = 'all 1s';
})